<!DOCTYPE html>
<html lang="zh-CN">

<#assign html_title="搬砖之家">
    <head>
        <#include "/components/head.htm"   />
    </head>
    <body>
    <div id="fullPage">
        <!--Page One-->
        <#include "/components/header.section.htm"   />

        <section>
            <div class="container white-block">
                <h3>个人信息</h3>
                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-3">昵称</div>
                    <div class="col-md-3">${user.nick_name!"未设置"}</div>
                </div>
                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-3">手机号码</div>
                    <div class="col-md-3">${user.phone}</div>
                </div>
                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-3">电子邮箱</div>
                    <div class="col-md-3">${user.mail!"未绑定"}</div>
                </div>
                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-3">注册时间</div>
                    <div class="col-md-3">${user.create_time?string("yyyy-MM-dd HH:mm:ss")}</div>
                </div>
                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-3">最后注册时间</div>
                    <div class="col-md-3">${user.last_login_time?string("yyyy-MM-dd HH:mm:ss")}</div>
                </div>
                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-3">密码</div>
                    <div class="col-md-3">
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">修改新密码 </button>
                    </div>
                </div>
                <br></br>

            </div>
        </section>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">设置新密码</h4>
                    </div>
                    <div class="modal-body">

                        <form class="form-horizontal" >
                            <div class="form-group">
                                <label  class="col-sm-3 control-label">旧密码 *</label>
                                <div class="col-sm-6">
                                    <input type="password" class="form-control" placeholder="密码" name="old_password">
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-3 control-label">新密码 *</label>
                                <div class="col-sm-6">
                                    <input type="password" class="form-control" placeholder="密码" name="new_password">
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-3 control-label">重复新密码 *</label>
                                <div class="col-sm-6">
                                    <input type="password" class="form-control"  placeholder="密码" name="new_password2">
                                </div>
                            </div>

                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="newPwdBtn">确认修改</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </body>
    <script>
        $(document).ready(function () {
            $("#newPwdBtn").click(function () {
                $.ajax({
                    method:'post',
                    url:'/api/user/new_passwd',
                    data:$('form').serialize(),
                    success:function (response) {
                        alert(response.message);
                        if(response.success){
                            window.location.href="/view/user/profile";
                        }
                    }
                })
            })
        });
    </script>
</html>